﻿
Namespace LightSwitchApplication

    Public Class CreateNewCustomer

        Private Sub CreateNewCustomer_InitializeDataWorkspace(saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService))
            ' Write your code here.
            Dim userDetails = Me.DataWorkspace.ApplicationData.GetUserByUsername(Me.Application.User.Name)
            Me.CustomerProperty = New Customer()
            Me.Text_ScreenTitle = "New Customer"
            Me.CustomerProperty.Country = "Australia"
            Me.CustomerProperty.User = userDetails.FirstOrDefault
        End Sub

        Private Sub CreateNewCustomer_Saved()
            '' Write your code here.
            'Me.Close(False)
            'Application.Current.ShowDefaultScreen(Me.CustomerProperty)
        End Sub

        Private Sub NewAppointmentMethod_Execute()
            ' Write your code here.
            Me.Application.ShowCreateNewAppointment(Me.CustomerProperty.Id)
        End Sub

        Private Sub NewAppointmentMethod_CanExecute(ByRef result As Boolean)
            ' Write your code here.
            result = (Me.CustomerProperty.Details.EntityState <> EntityState.Added)
        End Sub
    End Class

End Namespace